package com.tgy.Request;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Arrays;

/***
 * @ClassName: LoginServlet
 * @Description: 使用request获取前端数据
 * @Auther: 送一一块二向箔
 * @Date: 0:35 2021/12/5
 * @version : V1.0
 */
public class LoginServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String username = req.getParameter("username");
        String password = req.getParameter("password");
        String[] hobbies = req.getParameterValues("hobby");
        System.out.println(username+password);
        System.out.println(Arrays.toString(hobbies));
        //通过请求转发
        //这里的 /  代表当前的web应用
        req.getRequestDispatcher("/success.html").forward(req,resp);
    }
}
